package com.iptv.live.controller;

import com.iptv.live.domain.LiveTypeTable;
import com.iptv.live.domain.dto.LiveTypeTableAddDTO;
import com.iptv.live.domain.dto.LiveTypeTableEditDTO;
import com.iptv.live.domain.vo.LiveTypeTableVO;
import com.iptv.live.service.ILiveTypeTableService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iptv.common.annotation.Log;
import com.iptv.common.core.controller.BaseController;
import com.iptv.common.core.domain.AjaxResult;
import com.iptv.common.enums.BusinessType;
import com.iptv.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 直播频道分类Controller
 * 
 * @author Cinzia
 * @date 2025-01-03
 */
@RestController
@RequestMapping("/live-type")
public class LiveTypeTableController extends BaseController
{
    @Autowired
    private ILiveTypeTableService liveTypeTableService;

    /**
     * 查询直播频道分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LiveTypeTable liveTypeTable)
    {
        startPage();
        List<LiveTypeTableVO> list = liveTypeTableService.selectLiveTypeTableList(liveTypeTable);
        return getDataTable(list);
    }

//    /**
//     * 导出直播频道分类列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:table:export')")
//    @Log(title = "直播频道分类", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, LiveTypeTable liveTypeTable)
//    {
//        List<LiveTypeTable> list = liveTypeTableService.selectLiveTypeTableList(liveTypeTable);
//        ExcelUtil<LiveTypeTable> util = new ExcelUtil<LiveTypeTable>(LiveTypeTable.class);
//        util.exportExcel(response, list, "直播频道分类数据");
//    }

    /**
     * 获取直播频道分类详细信息
     */
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return success(liveTypeTableService.selectLiveTypeTableByTypeId(typeId));
    }

    /**
     * 新增直播频道分类
     */
    @Log(title = "直播频道分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveTypeTableAddDTO liveTypeTableAddDTO)
    {
        return toAjax(liveTypeTableService.insertLiveTypeTable(liveTypeTableAddDTO));
    }

    /**
     * 修改直播频道分类
     */
    @Log(title = "直播频道分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveTypeTableEditDTO liveTypeTableEditDTO)
    {
        return toAjax(liveTypeTableService.updateLiveTypeTable(liveTypeTableEditDTO));
    }

    /**
     * 删除直播频道分类
     */
    @Log(title = "直播频道分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(liveTypeTableService.deleteLiveTypeTableByTypeIds(typeIds));
    }

}
